package com.itheima.filter;

import com.itheima.interceptor.DemoInterceptor2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/****
 * 注册拦截器
 */
@Component
public class WebConfig implements WebMvcConfigurer {

    //1、将拦截器注入
    @Autowired
    private DemoInterceptor2 demoInterceptor2;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //2、重写注册拦截器的方法
        registry.addInterceptor(demoInterceptor2)
                .addPathPatterns("/**");
    }
}